<?php
use app\ErrorCode;

if (!function_exists("jsonResponse")) {
    function jsonResponse($data, $code = ErrorCode::SUCCESS) {
        $result = [
            "code" => $code,
            "data" => $data
        ];

        return json($result);
    }
}

if (!function_exists('arrResponse')) {
    function arrResponse($obj): array
    {
        return empty($obj) ? [] : $obj->toArray();
    }
}